/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmpp.client.api.Group;

import java.util.ArrayList;

/**
 *
 * @author Miguel Gonzalez - Juanan Mangudo - Telecor
 */
public class GroupXMPP {
    private String name;
    private String description;
    private String displayName;
    private String showInRoster;
    private ArrayList<String> members;
    private ArrayList<String> administrators;
    private ArrayList<String> groupList;
    
    /**
     * Constructs a new group. Note: this constructor is intended for implementors of the
     * {@link GroupProvider} interface. To create a new group, use the
     * {@link GroupManager#createGroup(String)} method. 
     *
     * @param name the name.
     * @param description the description.
     * @param members a Collection of the group members.
     * @param administrators a Collection of the group administrators.
     */
    public GroupXMPP(String name, String description, ArrayList<String> members,
            ArrayList<String> administrators, String displayName, String showInRoster,
            ArrayList<String> groupList) throws GroupCreateException
    {
        if(name == null || name.isEmpty()) {
            throw new GroupCreateException("El nombre no puede estar vacío");
        }
        this.name = name;
        if(description == null) {
            this.description = "";
        } else {
            this.description = description;
        }
        
        if(members == null) {
            this.members = new ArrayList<String>();
        } else {
            this.members = members;
        }
        
        if(administrators == null) {
            this.administrators = new ArrayList<String>();
        } else {
            this.administrators = administrators;
        }
        
        if(displayName==null) {
            this.displayName = "";
        } else {
            this.displayName = displayName;
        }
        
        if(showInRoster == null) {
            this.showInRoster = "nobody";
        } else {
            if(showInRoster.equals(GroupsXMPP.SHOWINROSTER_EVERYBODY) || showInRoster.equals(GroupsXMPP.SHOWINROSTER_NOBODY) ||
                    showInRoster.equals(GroupsXMPP.SHOWINROSTER_ONLYGROUP)) {
                this.showInRoster = showInRoster;
            } else {
                throw new GroupCreateException("ShowInRoster inválido");
            }
        }
        
        if(groupList == null) {
            this.groupList = new ArrayList<String>();
        } else {
            this.groupList = groupList;
        }
    }
    
    public String getDisplayName() {
        return displayName;
    }
    
    public String getShowInRoster() {
        return showInRoster;
    }
    
    public ArrayList<String> groupList() {
        return groupList;
    }
    
    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public ArrayList<String> getMembers() {
        return members;
    }

    public ArrayList<String> getAdministrators() {
        return administrators;
    }
}
